package ynu.edu;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.client.RestTemplate;
import ynu.edu.config.RandomLoadBalancerConfiguration;

@SpringBootApplication
@EnableFeignClients
@EnableAspectJAutoProxy // 启用AOP支持，让Resilience4j注解生效
// 应用随机负载均衡策略
@LoadBalancerClient(name="provider-service", configuration = RandomLoadBalancerConfiguration.class)
public class ConsumerApplication16000 {

    /**
     * RestTemplate配置
     * 注释掉@LoadBalanced让Gateway来处理负载均衡
     */
    @Bean
    // @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication16000.class, args);
    }
}
